package com.qingxin.park.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.annotations.GenericGenerator;

/**
 * 农作物表
 */
@Entity
@Table(name = "crops_yz")
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class Cropsyz extends com.qingxin.sys.entity.BaseEntity implements
		java.io.Serializable {
	private static final long serialVersionUID = 3493991120466841777L;
	
	private String cropid;
	private CropsyzType cropsyzType;
	private String cropCode;
	private String cropName;
	private String cropImg;
	private String units;
	private String remark;
	private String createBy;
	private Date createTime;
	private String updateBy;
	private Date updateTime;
	private Set<ProductionLink> productionLinks = new HashSet<>(0);

	// Constructors

	/** default constructor */
	public Cropsyz() {
	}
	
	
	public Cropsyz(String cropid) {
		this.cropid = cropid;
	}


	public Cropsyz(String cropid, String cropName) {
		this.cropid = cropid;
		this.cropName = cropName;
	}



	public Cropsyz(String cropid, String cropCode, String cropName,
			String units, Date createTime, String typeName) {
		this.cropid = cropid;
		this.cropCode = cropCode;
		this.cropName = cropName;
		this.units = units;
		this.createTime = createTime;
		cropsyzType = new CropsyzType(null, typeName);
	}


	/** full constructor */
	public Cropsyz(CropsyzType cropsyzType, String cropCode, String cropName,
			String cropImg, String units, String remark, String createBy,
			Date createTime, String updateBy, Date updateTime,
			Set<ProductionLink> productionLinks) {
		this.cropsyzType = cropsyzType;
		this.cropCode = cropCode;
		this.cropName = cropName;
		this.cropImg = cropImg;
		this.units = units;
		this.remark = remark;
		this.createBy = createBy;
		this.createTime = createTime;
		this.updateBy = updateBy;
		this.updateTime = updateTime;
		this.productionLinks = productionLinks;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "cropid", unique = true, nullable = false, length = 32)
	public String getCropid() {
		return this.cropid;
	}

	public void setCropid(String cropid) {
		this.cropid = cropid;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "typeid")
	public CropsyzType getCropsyzType() {
		return this.cropsyzType;
	}

	public void setCropsyzType(CropsyzType cropsyzType) {
		this.cropsyzType = cropsyzType;
	}

	@Column(name = "crop_code", length = 20)
	public String getCropCode() {
		return this.cropCode;
	}

	public void setCropCode(String cropCode) {
		this.cropCode = cropCode;
	}

	@Column(name = "crop_name", length = 50)
	public String getCropName() {
		return this.cropName;
	}

	public void setCropName(String cropName) {
		this.cropName = cropName;
	}

	@Column(name = "crop_img", length = 100)
	public String getCropImg() {
		return this.cropImg;
	}

	public void setCropImg(String cropImg) {
		this.cropImg = cropImg;
	}

	@Column(name = "units", length = 20)
	public String getUnits() {
		return units;
	}

	public void setUnits(String units) {
		this.units = units;
	}

	@Column(name = "remark", length = 1000)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "create_by", length = 32)
	public String getCreateBy() {
		return this.createBy;
	}

	public void setCreateBy(String createBy) {
		this.createBy = createBy;
	}

	@Column(name = "create_time", length = 23)
	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "update_by", length = 32)
	public String getUpdateBy() {
		return this.updateBy;
	}

	public void setUpdateBy(String updateBy) {
		this.updateBy = updateBy;
	}

	@Column(name = "update_time", length = 23)
	public Date getUpdateTime() {
		return this.updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "crops")
	@JsonIgnore
	public Set<ProductionLink> getProductionLinks() {
		return this.productionLinks;
	}

	public void setProductionLinks(Set<ProductionLink> productionLinks) {
		this.productionLinks = productionLinks;
	}

}